
//@符号表示 src路径
//导入aixos对象
import request from "@/utils/request"
//登录,data对象,传后端的数据

//登录,data对象,传后端的数据
const login = (data) => {
    //调用axios
    return request({
        // /api/login代理成 http://localhost:8080/login 进行访问
        url: "/api/users/login",
        method: "post",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        //简化属性
        data
    })
}
const findById = (id) => {
    return request({
        url: `/api/users/find/${id}`,
        method: "get"
    })
}

const save = (data) => {
    return request({
        url: "/api/users/save",
        method: "post",
        //表示请求的数据格式为json
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}
const register = (data) => {
    return request({
        url: "/api/user/register",
        method: "post",
        //表示请求的数据格式为json
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}


//根据id删除用户
const deleteUserById = (id) => {
    return request({
        url: `/api/users/delete/${id}`,
        method: "get"
    })
}
const selectCartInfo = (uid)=>{
    return request({
        url: `/api/users/selectCartInfo`,
        headers: { "Content-Type": "application/json;charset=utf-8" },
        method: "post",
        data: {
            id: uid
        }
    })
}

const updatePassword = (data) => {
    return request({
        url: "/api/users/updatePassword",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        method: "post",
        data
    })
}

const updateUserInfo = (data) => {
    return request({
        url: "/api/users/updateUserInfo",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        method: "post",
        data
    })
}

export { login, findById, save, deleteUserById, register,selectCartInfo,updatePassword,updateUserInfo }
